A Bytecode Alliance project
posish provides efficient memory-safe and I/O-safe wrappers to "POSIX-ish"
libc APIs and syscalls, with configurable backends. It uses Rust references,
slices, and return values instead of raw pointers, and io-lifetimes instead
of raw file descriptors, providing memory safety and I/O safety. It uses
Results for reporting errors, bitflags instead of bare integer flags,
an Arg trait with optimizations to efficiently accept any Rust string type,
and several other efficient conveniences.
posish is low-level and does not support Windows; for higher-level and more
portable APIs built on this functionality, see the system-interface,
cap-std, and fs-set-times crates, for example.
Posish currently has two backends available: libc and linux_raw.
The libc backend is enabled by default and uses the widely-used libc
crate which provides bindings to native libc libraries and is portable to
many OS's.
The linux_raw backend can be enabled by setting the RUSTFLAGS environment
variable to --cfg linux_raw, and uses raw Linux system calls and vDSO calls.
This only supports Linux, currently on x86-64, x86, and aarch64. It supports
stable as well as nightly Rust.
- By being implemented entirely in Rust, avoiding
libc,errno, and pthread cancellation, and employing some specialized optimizations, most functions inlinux_rawcompile down to very efficient code. On nightly Rust, they can often be fully inlined into user code. - Most functions in
linux_rawpreserve memory and I/O safety all the way down to the syscalls. linux_rawuses a 64-bittime_ttype on all platforms, avoiding the y2038 bug.